import re

from flask import Blueprint,request,make_response,jsonify,redirect
from flask_restful import reqparse
from util.myjwt import myjwt
from util.captcha.captcha import captcha
import json, random, time, requests
from util.myredis import r
from util.smscode import sms_code
from models.user import *
from util.comm import get_ali_object, md5

echarts_blue = Blueprint("echarts",__name__)



@echarts_blue.route('/getecharts')
def getecharts():
    # select DATE_FORMAT(create_time,'%Y-%m-%d'),count(*) from user group by DATE_FORMAT(create_time,'%Y-%m-%d');//按天统计数据
    # select DATE_FORMAT(create_time,'%Y-%m-%d') month ,count(*) c from user group by month;//按天统计数据

    sql = db.session.execute("select DATE_FORMAT(create_time,'%Y-%m-%d') month ,count(*) c from user group by month")
    print(sql)
    list = []

    for i in sql:
        list.append({'value':i.c,'name':i.month})
    print(list)
    return jsonify({'code':200,'data':list})














